<?php
	include("Connection.php");
	class Database{
		
		public function getListCategoriesForApps(){
			$sql = "SELECT TEN_DANH_MUC, MA_DANH_MUC FROM danh_muc WHERE THE_LOAI='Applications'";
			return  mysql_query($sql);	
		}
		
		public function getListCategoriesForGame(){
			$sql = "SELECT TEN_DANH_MUC, MA_DANH_MUC FROM danh_muc WHERE THE_LOAI='Game'";
			return  mysql_query($sql);
		}
		
		public function checkCate($game, $app){
			$sql1 = "SELECT TEN_DANH_MUC FROM danh_muc WHERE THE_LOAI='$app' AND THE_LOAI='$game'";
			$count = @mysql_num_rows(@mysql_query($sql1));
			
			if($count == 1)
					return true;
			else
				return false;
		}
		
		public function getProduct(){
			$sql = "SELECT STT, TEN_UNG_DUNG, avatar,ID FROM ung_dung LIMIT 0 , 12";
			return  mysql_query($sql);
		}
		
		public function getlistproductwithcate($ma){
			$sql = "SELECT * FROM ung_dung WHERE TRONG_DANH_MUC='$ma'";
			return mysql_query($sql);
		}
		
		public function search($for){
			$sql = "SELECT * FROM ung_dung WHERE TEN_UNG_DUNG LIKE '$for%'";
			return mysql_query($sql);
			
		}
		public function getIdForDetailPage($id){
			$sql = "select ID from images where ID_APP = '$id'";
			return mysql_query($sql);
		}
		
		public function getDiscription($id){
			$sql = "SELECT MO_TA FROM ung_dung where ID='$id'";
			return  mysql_query($sql);
		}
	}
?>